{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "import libraries"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "import os\n",
    "from pathlib import Path\n",
    "# xml library\n",
    "from xml.dom import minidom"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "Load labeled data, put them in a list\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "label_dir = ''\n",
    "label_fn_list = os.listdir(label_dir)\n",
    "\n",
    "for label_fn in label_fn_list:\n",
    "    label_path = os.path.join(label_dir, label_fn)\n",
    "    # read the label xml file\n",
    "    label_doc = minidom.parse(str(Path(label_path)))\n",
    "    \n",
    "    # retrieve the timestamep\n",
    "    time_stamp = label_doc.getElementsByTagName('filename')[0].childNodes[0].data\n",
    "    time_stamp = float(time_stamp.strip('.jpg'))\n",
    "    \n",
    "    # retrieve the bounding box\n",
    "    xmin = int(label_doc.getElementsByTagName('xmin')[0].childNodes[0].data)\n",
    "    ymin = int(label_doc.getElementsByTagName('ymin')[0].childNodes[0].data)\n",
    "    xmax = int(label_doc.getElementsByTagName('xmax')[0].childNodes[0].data)\n",
    "    ymax = int(label_doc.getElementsByTagName('ymax')[0].childNodes[0].data)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "kernelspec": {
   "name": "python3",
   "language": "python",
   "display_name": "Python 3"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}